🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / data / src / commonMain / kotlin / org / meshtastic / core / data / repository / RadioConfigRepositoryImpl.kt
Displaying Raw • Download
core/data/src/commonMain/kotlin/org/meshtastic/core/data/repository/RadioConfigRepositoryImpl.kt 878905aea3776316a2dbed2e441a2c4a16a8eba4 (878905ae) Text, 6.22 KB
T8b949e/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.data.repository
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.MutableStateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.asStateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.combine
Tff7b72import T7ee787org.koin.core.annotation.Single
Tff7b72import T7ee787org.meshtastic.core.datastore.ChannelSetDataSource
Tff7b72import T7ee787org.meshtastic.core.datastore.LocalConfigDataSource
Tff7b72import T7ee787org.meshtastic.core.datastore.ModuleConfigDataSource
Tff7b72import T7ee787org.meshtastic.core.model.util.getChannelUrl
Tff7b72import T7ee787org.meshtastic.core.repository.NodeRepository
Tff7b72import T7ee787org.meshtastic.core.repository.RadioConfigRepository
Tff7b72import T7ee787org.meshtastic.proto.Channel
Tff7b72import T7ee787org.meshtastic.proto.ChannelSet
Tff7b72import T7ee787org.meshtastic.proto.ChannelSettings
Tff7b72import T7ee787org.meshtastic.proto.Config
Tff7b72import T7ee787org.meshtastic.proto.DeviceProfile
Tff7b72import T7ee787org.meshtastic.proto.DeviceUIConfig
Tff7b72import T7ee787org.meshtastic.proto.FileInfo
Tff7b72import T7ee787org.meshtastic.proto.LocalConfig
Tff7b72import T7ee787org.meshtastic.proto.LocalModuleConfig
Tff7b72import T7ee787org.meshtastic.proto.ModuleConfig
T8b949e/**
* Class responsible for radio configuration data. Combines access to [nodeDB], [ChannelSet], [LocalConfig] &
* [LocalModuleConfig].
*/
Tf0883e@Single
Tff7b72open Tff7b72class T56d364RadioConfigRepositoryImplTb4b4b4(
Tff7b72private Tff7b72val Te6edf3nodeDBTb4b4b4: Te6edf3NodeRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3channelSetDataSourceTb4b4b4: Te6edf3ChannelSetDataSourceTb4b4b4,
Tff7b72private Tff7b72val Te6edf3localConfigDataSourceTb4b4b4: Te6edf3LocalConfigDataSourceTb4b4b4,
Tff7b72private Tff7b72val Te6edf3moduleConfigDataSourceTb4b4b4: Te6edf3ModuleConfigDataSourceTb4b4b4,
Tb4b4b4) Tb4b4b4: Te6edf3RadioConfigRepository Tb4b4b4{
T8b949e/** Flow representing the [ChannelSet] data store. */
Tff7b72override Tff7b72val Te6edf3channelSetFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3ChannelSetTff7b72> Tff7b72= Te6edf3channelSetDataSourceTb4b4b4.Te6edf3channelSetFlow
T8b949e/** Clears the [ChannelSet] data in the data store. */
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffclearChannelSetTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3channelSetDataSourceTb4b4b4.Te6edf3clearChannelSetTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/** Replaces the [ChannelSettings] list with a new [settingsList]. */
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffreplaceAllSettingsTb4b4b4(Te6edf3settingsListTb4b4b4: Te6edf3ListTff7b72<Te6edf3ChannelSettingsTff7b72>Tb4b4b4) Tb4b4b4{
Te6edf3channelSetDataSourceTb4b4b4.Te6edf3replaceAllSettingsTb4b4b4(Te6edf3settingsListTb4b4b4)
Tb4b4b4}
T8b949e/**
* Updates the [ChannelSettings] list with the provided channel and returns the index of the admin channel after the
* update (if not found, returns 0).
*
* @param channel The [Channel] provided.
* @return the index of the admin channel after the update (if not found, returns 0).
*/
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffupdateChannelSettingsTb4b4b4(Te6edf3channelTb4b4b4: Te6edf3ChannelTb4b4b4) Tff7b72= Te6edf3channelSetDataSourceTb4b4b4.Te6edf3updateChannelSettingsTb4b4b4(Te6edf3channelTb4b4b4)
T8b949e/** Flow representing the [LocalConfig] data store. */
Tff7b72override Tff7b72val Te6edf3localConfigFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3LocalConfigTff7b72> Tff7b72= Te6edf3localConfigDataSourceTb4b4b4.Te6edf3localConfigFlow
T8b949e/** Clears the [LocalConfig] data in the data store. */
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffclearLocalConfigTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3localConfigDataSourceTb4b4b4.Te6edf3clearLocalConfigTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/**
* Updates [LocalConfig] from each [Config] oneOf.
*
* @param config The [Config] to be set.
*/
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffsetLocalConfigTb4b4b4(Te6edf3configTb4b4b4: Te6edf3ConfigTb4b4b4) Tb4b4b4{
Te6edf3localConfigDataSourceTb4b4b4.Te6edf3setLocalConfigTb4b4b4(Te6edf3configTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3loraTff7b72?.Te6edf3let Tb4b4b4{ Te6edf3channelSetDataSourceTb4b4b4.Te6edf3setLoraConfigTb4b4b4(Tffa657itTb4b4b4) Tb4b4b4}
Tb4b4b4}
T8b949e/** Flow representing the [LocalModuleConfig] data store. */
Tff7b72override Tff7b72val Te6edf3moduleConfigFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3LocalModuleConfigTff7b72> Tff7b72= Te6edf3moduleConfigDataSourceTb4b4b4.Te6edf3moduleConfigFlow
T8b949e/** Clears the [LocalModuleConfig] data in the data store. */
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffclearLocalModuleConfigTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3moduleConfigDataSourceTb4b4b4.Te6edf3clearLocalModuleConfigTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/**
* Updates [LocalModuleConfig] from each [ModuleConfig] oneOf.
*
* @param config The [ModuleConfig] to be set.
*/
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffsetLocalModuleConfigTb4b4b4(Te6edf3configTb4b4b4: Te6edf3ModuleConfigTb4b4b4) Tb4b4b4{
Te6edf3moduleConfigDataSourceTb4b4b4.Te6edf3setLocalModuleConfigTb4b4b4(Te6edf3configTb4b4b4)
Tb4b4b4}
T8b949e// DeviceUIConfig is session-scoped data received fresh in every handshake — no persistence needed.
Tff7b72private Tff7b72val Te6edf3_deviceUIConfigFlow Tff7b72= Te6edf3MutableStateFlowTff7b72<Te6edf3DeviceUIConfig?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4)
Tff7b72override Tff7b72val Te6edf3deviceUIConfigFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3DeviceUIConfig?Tff7b72> Tff7b72= Te6edf3_deviceUIConfigFlowTb4b4b4.Te6edf3asStateFlowTb4b4b4(Tb4b4b4)
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffsetDeviceUIConfigTb4b4b4(Te6edf3configTb4b4b4: Te6edf3DeviceUIConfigTb4b4b4) Tb4b4b4{
Te6edf3_deviceUIConfigFlowTb4b4b4.Te6edf3value Tff7b72= Te6edf3config
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffclearDeviceUIConfigTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3_deviceUIConfigFlowTb4b4b4.Te6edf3value Tff7b72= Tff7b72null
Tb4b4b4}
T8b949e// FileInfo manifest is session-scoped: accumulated during STATE_SEND_FILEMANIFEST, cleared on each new handshake.
Tff7b72private Tff7b72val Te6edf3_fileManifestFlow Tff7b72= Te6edf3MutableStateFlowTff7b72<Te6edf3ListTff7b72<Te6edf3FileInfoTff7b72>Tff7b72>Tb4b4b4(Te6edf3emptyListTb4b4b4(Tb4b4b4)Tb4b4b4)
Tff7b72override Tff7b72val Te6edf3fileManifestFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3ListTff7b72<Te6edf3FileInfoTff7b72>Tff7b72> Tff7b72= Te6edf3_fileManifestFlowTb4b4b4.Te6edf3asStateFlowTb4b4b4(Tb4b4b4)
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffaddFileInfoTb4b4b4(Te6edf3infoTb4b4b4: Te6edf3FileInfoTb4b4b4) Tb4b4b4{
Te6edf3_fileManifestFlowTb4b4b4.Te6edf3value Tff7b72+Tff7b72= Te6edf3info
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffclearFileManifestTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3_fileManifestFlowTb4b4b4.Te6edf3value Tff7b72= Te6edf3emptyListTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/** Flow representing the combined [DeviceProfile] protobuf. */
Tff7b72override Tff7b72val Te6edf3deviceProfileFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3DeviceProfileTff7b72> Tff7b72=
Te6edf3combineTb4b4b4(Te6edf3nodeDBTb4b4b4.Te6edf3ourNodeInfoTb4b4b4, Te6edf3channelSetFlowTb4b4b4, Te6edf3localConfigFlowTb4b4b4, Te6edf3moduleConfigFlowTb4b4b4) Tb4b4b4{
Te6edf3nodeTb4b4b4,
Te6edf3channelsTb4b4b4,
Te6edf3localConfigTb4b4b4,
Te6edf3localModuleConfigTb4b4b4,
Tff7b72-Tff7b72>
Te6edf3DeviceProfileTb4b4b4(
Te6edf3long_name Tff7b72= Te6edf3nodeTff7b72?.Te6edf3userTff7b72?.Te6edf3long_nameTb4b4b4,
Te6edf3short_name Tff7b72= Te6edf3nodeTff7b72?.Te6edf3userTff7b72?.Te6edf3short_nameTb4b4b4,
Te6edf3channel_url Tff7b72= Te6edf3channelsTb4b4b4.Te6edf3getChannelUrlTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3config Tff7b72= Te6edf3localConfigTb4b4b4,
Te6edf3module_config Tff7b72= Te6edf3localModuleConfigTb4b4b4,
Te6edf3fixed_position Tff7b72=
Tff7b72if Tb4b4b4(Te6edf3node Tff7b72!Tff7b72= Tff7b72null Tff7b72&Tff7b72& Te6edf3localConfigTb4b4b4.Te6edf3positionTff7b72?.Te6edf3fixed_position Tff7b72=Tff7b72= Tff7b72trueTb4b4b4) Tb4b4b4{
Te6edf3nodeTb4b4b4.Te6edf3position
Tb4b4b4} Tff7b72else Tb4b4b4{
Tff7b72null
Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.05s